package com.open.exam.message;

import com.open.exam.businessservice.ExamPlanBussinessService;
import com.open.exam.utils.FileUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Description 消息处理器
 * @author 奶茶
 * Created by on 2019/3/4 17:09.
 */
@Component
public class MessageReceiver {

    private static final Logger logger = LoggerFactory.getLogger(MessageReceiver.class);

    @Autowired
    private ExamPlanBussinessService examPlanBussinessService;

    /**
     * 监听考试计划队列
     * @param examPlanUrl 考试计划包url
     */
    @RabbitListener(queues = "topic.examPlan.url")
    public void processMessage(String examPlanUrl){
        logger.info("EXAM_PLAN_URL:" + examPlanUrl);
        if(FileUtil.isFileExsit(examPlanUrl)){
            examPlanBussinessService.importExamPlanData(examPlanUrl,false);
        }
    }
}
